import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
// import { Observable } from 'rxjs';
import { UserService } from 'src/user/user.service';

@Injectable()
export class AdminGuard implements CanActivate {
  constructor(private userSerive: UserService) {}
  async canActivate(context: ExecutionContext): Promise<boolean> {
    const req = context.switchToHttp().getRequest();
    console.log('🚀 ~ AdminGuard ~ ruslut:', req.user);
    const user = await this.userSerive.find(req.user.username);
    console.log('🚀 ~ AdminGuard ~ user:', user);
    // if (!user.email) {
    //   return false;
    // }
    return true;
  }
}
